package cc.lecaicai.mcp.server.computer;

import cc.lecaicai.mcp.server.computer.domain.service.ComputerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@Slf4j
@SpringBootApplication
//这个启动类为何要这么写，它继承的这个CommandLineRunner又是干什么的，如何在一个mcp server中起作用
//能否描述一下用java开发MCPserver的过程
public class McpServerComputerApplication implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(McpServerComputerApplication.class, args);
    }

    //这个配置类的作用是什么
    @Bean
    public ToolCallbackProvider computerTools(ComputerService computerService){
        return MethodToolCallbackProvider.builder().toolObjects(computerService).build();
    }

    @Override
    public void run(String... args) throws Exception{
        log.info("mcp server computer success!");
    }
}
